import 'package:cloudapp/pages/base.dart';
import 'package:cloudapp/utils/cloud_picture_source.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';

// 图片全屏浏览界面

class PictureViewer extends StatefulWidget {
  static const pageName = "/picture/viewer";
  final CloudPictureSource source;
  PictureViewer({Key key, @required this.source}):super(key: key);

  @override
  State<StatefulWidget> createState() {
    return _PictureViewer();
  }
}

class _PictureViewer extends BaseState<PictureViewer> {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: PhotoView.customChild(
        enableRotation: true,
        child: FadeInImage.memoryNetwork(
          placeholder: widget.source.thumb,
          image: widget.source.raw,
          placeholderScale: 0.1,
          fadeInDuration: const Duration(milliseconds: 1),
          fadeOutDuration: const Duration(milliseconds: 1),
        ),
      ),
    );
  }
}
